package com.apptravel.dao;

import com.apptravel.entity.Area;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component("areaDao")
public class AreaDAOImpl extends MybatisDao implements AreaDAO {

    public AreaDAOImpl() {
        super();
    }

    /**
     * 保存
     * @param record
     */
    public void insert(Area record) {
        this.getSqlSession().insert("area.insert", record);
    }

    /**
     * 更新.
     *
     * @param record
     */
    public void update(Area record){
        this.getSqlSession().update("area.updateById",record);
    }

    /**
     * 删除.
     * @param id
     */
    public void del(Long id){
        this.getSqlSession().delete("area.deleteById",id);
    }

    /**
     * 查找单例.
     *
     * @param id
     * @return
     */
    public Area selectById(Long id){
        return (Area)this.getSqlSession().selectOne("area.selectById",id);
    }



    /**
     * 不带页列表.
     *
     * @param params
     * @return
     */
    public List<Area> getListNoPage(Map<String,Object> params){
        return this.getSqlSession().selectList("area.selectByMap",params);
    }

    /**
     * 分页列表.
     * @param params
     * @param pageNo
     * @param pageSize
     * @return
     */
    public Page<Area> getList(Map<String,Object> params,int pageNo,int pageSize){
        params.put("page","");
        return this.selectPage("area.selectByMap",params,pageNo,pageSize);
    }

    
}